<?php
namespace App\Http\Controllers;

use App\Interfaces\Server;

class StartServer implements Server
{
    use \App\Traits\StartInitParam;

    private $_observers = array (); //观察者

    public function addObServer($observer)
    {
        // TODO: Implement addObServer() method.
        $this->_observers [] = $observer;
    }

    public function handleObServer($parameter)
    {
        self::init();//参数初始化
        foreach ( $this->_observers as $obs )
            $obs->onStartServer ( $this, $parameter );
    }
}

include_once(__DIR__ . '/../../Helpers/functions.php');
$Server = new StartServer();loadModel();
$ObServer = glob(__DIR__ . '/Start/*.php');
foreach ($ObServer as $obs) {
    $namespace = "\\App\\Http\\Controllers\\Start\\";
    $class = $namespace . pathinfo(basename($obs),PATHINFO_FILENAME);
    $Server->addObServer(new $class());
}
global $onStartParameter;
$Server->handleObServer($onStartParameter);
